﻿using System;
using System.Collections.Generic;
using NHibernate;
using YunBox2.Contracts;
using YunBox2.Contracts.Core;
using YunBox2.Contracts.FoundationModels;

using YunBox2.DAL;
using YunBox2.Server.Foundation;
using System.ServiceModel;
namespace YunBox2.Server.Services
{
	public partial class BoxService : IFoundationService
	{
		#region IFoundationService Members

		public IList<UOM> GetAllUOM()
		{
		    User user = GetMyProfile();
			var biz = new UOMBiz(DbHelper.GetCurrentSession(), user);
			return biz.GetAllBizObjects();
		}


		public UOM GetUOMByID(Guid id)
		{
			User user = GetMyProfile();
			var biz = new UOMBiz(DbHelper.GetCurrentSession(), user);
			return biz.Get(id);
		}

		public bool RemoveUOMByID(Guid id)
		{
			User user = GetMyProfile();
			var biz = new UOMBiz(DbHelper.GetCurrentSession(), user);
			return biz.Remove(id);
		}

		public UOM AddUOM(UOM uom)
		{
			User user = GetMyProfile();
			var biz = new UOMBiz(DbHelper.GetCurrentSession(), user);
			return biz.Save(uom);
		}

		public UOM UpdateUOM( UOM uom)
		{
			User user = GetMyProfile();
			var biz = new UOMBiz(DbHelper.GetCurrentSession(), user);
			return biz.Update(uom);
		}


		public IList<BoardMaterial> GetAllBoardMaterialList(Guid clientID)
		{
			User user = GetMyProfile();
			ISession session = DbHelper.GetCurrentSession();
			var op = new BoardMaterialBiz(session, user);
			return op.GetAllBizObjects();
		}


		public bool RemoveBoardMaterialById(Guid clientID, Guid id)
		{
			User user = GetMyProfile();
			ISession session = DbHelper.GetCurrentSession();
			var op = new BoardMaterialBiz(session, user);
			return op.Remove(id);
		}

		public BoardMaterial GetBoardMaterialById(Guid clientId, Guid id)
		{
			User user = GetMyProfile();
			ISession session = DbHelper.GetCurrentSession();
			var op = new BoardMaterialBiz(session, user);
			return op.Get(id);
		}

		public BoardMaterial AddBoardMaterial(Guid clientId, BoardMaterial boardMaterial)
		{
			User user = GetMyProfile();
			ISession session = DbHelper.GetCurrentSession();
			var op = new BoardMaterialBiz(session, user);
			return op.Save(boardMaterial);
		}

		public BoardMaterial UpdateBoardMaterial(Guid clientId, BoardMaterial boardMaterial)
		{
			User user = GetMyProfile();
			ISession session = DbHelper.GetCurrentSession();
			var op = new BoardMaterialBiz(session, user);
			return op.Update(boardMaterial);
		}

		public IList<BoardType> GetAllBoardTypeList(Guid clientId)
		{
			User user = GetMyProfile();
			ISession session = DbHelper.GetCurrentSession();
			var biz = new BoardTypeBiz(session, user);
			return biz.GetAllBizObjects();
		}

		public BoardType GetBoardTypeById(Guid clientId, Guid id)
		{
			User user = GetMyProfile();
			ISession session = DbHelper.GetCurrentSession();
			var biz = new BoardTypeBiz(session, user);
			return biz.Get(id);
		}

		public BoardType AddBoardType(Guid clientId, BoardType boardType)
		{
			User user = GetMyProfile();
			ISession session = DbHelper.GetCurrentSession();
			var biz = new BoardTypeBiz(session, user);
			return biz.Save(boardType);
		}

		public BoardType UpdateBoardType(Guid clientId, BoardType boardType)
		{
			User user = GetMyProfile();
			ISession session = DbHelper.GetCurrentSession();
			var biz = new BoardTypeBiz(session, user);
			return biz.Update(boardType);
		}

		public bool RemoveBoardTypeById(Guid clientId, Guid id)
		{
			User user = GetMyProfile();
			ISession session = DbHelper.GetCurrentSession();
			var biz = new BoardTypeBiz(session, user);
			return biz.Remove(id);
		}

		#endregion

       
	}
}